/**
 * Created by thinkl on 2017/6/19.
 */
$(function () {
    var app_data = {
        search_list: [],
        commodity_list: [],
        commodity_class_list: [],
    };
    var app = new Vue({
            el: '#commonity_list',
            data: app_data,
            methods: {
                search_commodity: function () {
                    var price1 = $('#price1').val();
                    var price2 = $('#price2').val();
                    var com_class = $('#com_classification').val();
                    $.post('/commodity/query_commodity_search', {
                        price1: price1,
                        price2: price2,
                        com_classification: com_class
                    }, function (data) {
                        var l = JSON.parse(data);
                        app_data.search_list = l.result;
                    })
                },
                go_commodity_detail: function (id) {
                    location.href = '/static/commodity_detail/commodity_detail.html?id=' + id
                },
                go_add_img: function (id) {
                    location.href = '/static/commodity-list/add_img.html?id=' + id
                }
            }

        })
    ;
    $.post('/commodity/query_commodity', {}, function (data) {
        var arg = JSON.parse(data);
        app_data.commodity_list = arg.result
    });
    $.post('/commodity/query_commodity_class', {}, function (data) {
        var l = JSON.parse(data);
        app_data.commodity_class_list = l.result;
    });
});
function go_create_commodity() {
    location.href = '/static/create_commodity/create_commodity.html'
}

function go_commodity_purchase() {
    location.href = '/static/commodity_detail/commodity_detail.html'
}
